<div class="<?php echo $this->class; ?>"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
	<?php if ($this->headline): ?>
		<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
	<?php endif; ?>
	
	<div class="task">
		<div class="definition">
			<div class="title"><?php echo($this->task['name']); ?></div>
			<div class="created"><span class="user"><?php echo($this->task['created_user']); ?></span>(<span class="date"><?php echo($this->task['created_date']); ?></span>(<span class="time"><?php echo($this->task['created_time']); ?></span>))</div>
			<div class="description"><?php echo($this->task['description']); ?></div>
			<div class="type">Type: <?php echo($this->types[$this->task['task_type']]['name']); ?></div>
			<div class="labels">Labels: <?php if(is_array($this->task['labels'])): for($i=0;$i<=count($this->task['labels']);$i++): if($this->task['labels'][$i]!=""): echo('<span class="label">' . $this->labels[$this->task['labels'][$i]]['name'] . '</span>'); endif; endfor; endif; ?></div>
			<div class="owners">Owners:<?php if(is_array($this->task['owners'])): for($i=0;$i<=count($this->task['owners']);$i++): if($this->task['owners'][$i]!=""): echo('<span class="username">' . $this->owners[$this->task['owners'][$i]]['username'] . '</span>'); endif; endfor; endif; ?></div>
			<div class="cc">CC: <?php if(is_array($this->task['ccs'])): for($i=0;$i<=count($this->task['ccs']);$i++): if($this->task['ccs'][$i]!=""): echo('<span class="cc">' . $this->ccs[$this->task['ccs'][$i]]['username'] . '</span>'); endif; endfor; endif; ?></div>
		</div>
		<div class="comments">
			<?php if(count($this->comments)>0): ?>
				<?php foreach($this->comments as $comment): ?>
					<div class="comment <?php echo($comment['class']); ?>">
						<div class="created"><a name="<?php echo($comment['comment_no']); ?>">Comment #<?php echo($comment['comment_no']); ?></a> <span class="user"><?php echo($comment['created_user']); ?></span>(<span class="date"><?php echo($comment['created_date']); ?></span>(<span class="time"><?php echo($comment['created_time']); ?></span>))</div>
						<div class="description"><?php echo($comment['description']); ?></div>
						<?php if($comment['task_changed']==1): ?>
							<div class="changes">Changes
								<?php if($comment['changes_owners']['changed']==1): ?>
									<div class="owner">Owners:
										<?php if($comment['changes_owners']['added_changed']==1): ?>
											<span class="added">
												<?php for($i=0;$i<=count($comment['changes_owners']['added']);$i++): if($comment['changes_owners']['added'][$i]!=''): echo('+' . $this->owners[$comment['changes_owners']['added'][$i]]['username']); endif; endfor;?>
											</span>
										<?php endif; ?>
										<?php if($comment['changes_owners']['removed_changed']==1): ?>
											<span class="removed">
												<?php for($i=0;$i<=count($comment['changes_owners']['removed']);$i++): if($comment['changes_owners']['removed'][$i]!=''): echo('-' . $this->owners[$comment['changes_owners']['removed'][$i]]['username']); endif; endfor;?>
											</span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
								<?php if($comment['changes_ccs']['changed']==1): ?>
									<div class="cc">CCs:
										<?php if($comment['changes_ccs']['added_changed']==1): ?>
											<span class="added">
												<?php for($i=0;$i<=count($comment['changes_ccs']['added']);$i++): if($comment['changes_ccs']['added'][$i]!=''): echo("+" . $this->ccs[$comment['changes_ccs']['added'][$i]]['username']); endif; endfor;?>
											</span>
										<?php endif; ?>
										<?php if($comment['changes_ccs']['removed_changed']==1): ?>
											<span class="removed"><?php 
												for($i=0;$i<=count($comment['changes_ccs']['removed']);$i++): if($comment['changes_ccs']['removed'][$i]!=""): echo("-" . $this->ccs[$comment['changes_ccs']['removed'][$i]]['username']); endif; endfor;?>
											</span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
								<?php if($comment['changes_status']['changed']==1): ?>
									<div class="status">Status: 
										<?php if($comment['changes_status']['added_changed']==1): ?>
											<span class="added"><?php if($comment['changes_status']['added']!=""): echo("+" . $this->statuses[$comment['changes_status']['added']]['name']); endif;?></span>
										<?php endif; ?>
										<?php if($comment['changes_status']['removed_changed']==1): ?>
											<span class="removed"><?php if($comment['changes_status']['removed']!=""): echo("-" . $this->statuses[$comment['changes_status']['removed']]['name']); endif; ?></span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
								<?php if($comment['changes_status_type']['changed']==1): ?>
									<div class="statustype">Status type:
										<?php if($comment['changes_status_type']['added_changed']==1): ?>
											<span class="added"><?php if($comment['changes_status_type']['added']!=""): echo("+" . $this->status_types[$comment['changes_status_type']['added']]); endif; ?></span>
										<?php endif; ?>
										<?php if($comment['changes_status_type']['removed_changed']==1): ?>
											<span class="removed"><?php if($comment['changes_status_type']['removed']!=""): echo("-" . $this->status_types[$comment['changes_status_type']['removed']]); endif; ?></span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
								<?php if($comment['changes_labels']['changed']==1): ?>
									<div class="label">Labels: 
										<?php if($comment['changes_labels']['added_changed']==1): ?>
											<span class="added">
											<?php for($i=0;$i<=count($comment['changes_labels']['added']);$i++): if($comment['changes_labels']['added'][$i]!=""): echo("+" . $this->labels[$comment['changes_labels']['added'][$i]]['name']); endif; endfor;?>
											</span>
										<?php endif ?>
										<?php if($comment['changes_labels']['removed_changed']==1): ?>
											<span class="removed">
											<?php for($i=0;$i<=count($comment['changes_labels']['removed']);$i++): if($comment['changes_labels']['removed'][$i]!=""): echo("-" . $this->labels[$comment['changes_labels']['removed'][$i]]['name']); endif; endfor;?>
											</span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
								<?php if($comment['changes_type']['changed']==1): ?>
									<div class="type">Type:
										<?php if($comment['changes_type']['added_changed']==1): ?>
											<span class="added"><?php if($comment['changes_type']['added']!=""): echo("+" . $this->types[$comment['changes_type']['added']]['name']); endif;?></span>
										<?php endif; ?>
										<?php if($comment['changes_type']['removed_changed']==1): ?>
											<span class="removed"><?php if($comment['changes_type']['removed']!=""): echo("-" . $this->types[$comment['changes_type']['removed']]['name']); endif; ?></span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
								<?php if($comment['changes_priority']['changed']==1): ?>
									<div class="priority">Priority:
										<?php if($comment['changes_priority']['added_changed']==1): ?>
											<span class="added"><?php if($comment['changes_priority']['added']!=""): echo("+" . $this->priorities[$comment['changes_priority']['added']]['name']); endif;?></span>
										<?php endif; ?>
										<?php if($comment['changes_priority']['removed_changed']==1): ?>
											<span class="removed"><?php if($comment['changes_priority']['removed']!=""): echo("-" . $this->priorities[$comment['changes_priority']['removed']]['name']); endif; ?></span>
										<?php endif; ?>
									</div>
								<?php endif; ?>
							</div>
						<?php endif; ?>
						<?php if($comment['changed']==1): ?>
							<div class="lastchange">Last change on <?php echo($comment['last_change_date']); ?> <?php echo($comment['last_change_time']); ?> by <?php echo($comment['last_change_user']); ?>. Reason: <?php echo($comment['last_change_reason']); ?></div>
						<?php endif; ?>
					</div>
				<?php endforeach; ?>
			<?php else: /*<?php if(count($this->comments)>0):*/ ?>
			No Comments
			<?php endif; /*<?php if(count($this->comments)>0):*/ ?>
		</div>
	</div>
	
	<?php if($this->member_loggedin==true): ?>
	<div class="writecomment">
		Write a comment as <?php echo($this->member['id']); ?> (<?php echo($this->member['firstname']); ?> <?php echo($this->member['lastname']); ?>)
		<form action="<?php echo($href=$this->Environment->url . $this->Environment->requestUri); ?>" method="post">
			Comment:
			<textarea name="description" cols=40 row=6></TEXTAREA><br />
			Type:
			<select name="type">
					
						<?php foreach($this->types as $type): ?>
							<option <?php if ($type['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($type['id']); ?>"><?php echo($type['name']); ?></option>
						<?php endforeach; ?>
					
			</select><br />
			Labels:
			<select name="labels[]" multiple size=5>
					
						<?php foreach($this->labels as $label): ?>
							<option <?php if ($label['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($label['id']); ?>"><?php echo($label['name']); ?></option>
						<?php endforeach; ?>
					
			</select><br />
			Status:
			<select name="status">
					<optgroup label="Open">
						<?php foreach($this->open_statuses as $status): ?>
							<option <?php if ($status['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($status['id']); ?>"><?php echo($status['name']); ?></option>
						<?php endforeach; ?>
					</optgroup>
					<optgroup label="Working">
						<?php foreach($this->working_statuses as $status): ?>
							<option <?php if ($status['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($status['id']); ?>"><?php echo($status['name']); ?></option>
						<?php endforeach; ?>
					</optgroup>
					<optgroup label="Closed">
						<?php foreach($this->closed_statuses as $status): ?>
							<option <?php if ($status['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($status['id']); ?>"><?php echo($status['name']); ?></option>
						<?php endforeach; ?>
					</optgroup>					
					
			</select><br />
			Priority:
			<select name="priority">
					
						<?php foreach($this->priorities as $priority): ?>
							<option <?php if ($priority['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($priority['id']); ?>"><?php echo($priority['name']); ?></option>
						<?php endforeach; ?>
					
			</select><br />
			Owner:
			<select name="owners[]" multiple size=5>
					
						<?php foreach($this->owners as $owner): ?>
							<option <?php if ($owner['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($owner['id']); ?>"><?php echo($owner['firstname']); ?> <?php echo($owner['lastname']); ?> (<?php echo($owner['username']); ?>)</option>
						<?php endforeach; ?>
					
			</select><br />
			CC:
			<select name="ccs[]" multiple size=5>
					
						<?php foreach($this->ccs as $cc): ?>
							<option <?php if ($cc['selected']==true): ?>selected="selected" <?php endif; ?>value="<?php echo($cc['id']); ?>"><?php echo($cc['firstname']); ?> <?php echo($cc['lastname']); ?> (<?php echo($cc['username']); ?>)</option>
						<?php endforeach; ?>
					
			</select><br />
			<input type="hidden" name="taskid" value="<?php echo ($this->task['id']); ?>">
			<input type="hidden" name="userid" value="<?php echo($this->member['id']); ?>">
			<input type="hidden" name="mode" value="new">
			<input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">
			<input type="submit" name="submit" value="Submit" />
		</form>
	</div>
	<?php endif; ?>
</div>